/**
 * =====================================================================================
 *       @file  ngx_event_posted.h
 *      @brief  
 *
 *  Detailed description starts here.
 *
 *   @internal
 *     Created  2012年05月14日 20时22分47秒 
 *    Revision  1.0.0.0
 *    Compiler  gcc/g++
 *
 *     @author  luis
 * =====================================================================================
 */

#ifndef H_NGX_EVENT_POSTED_H_INCLUDED_
#define H_NGX_EVENT_POSTED_H_INCLUDED_

#include "ngx_event.h"

#define ngx_locked_post_event(ev, queue)                                      \
                                                                              \
    if (ev->prev == NULL) {                                                   \
        ev->next = (ngx_event_t *) *queue;                                    \
        ev->prev = (ngx_event_t **) queue;                                    \
        *queue = ev;                                                          \
                                                                              \
        if (ev->next) {                                                       \
            ev->next->prev = &ev->next;                                       \
        }                                                                     \
                                                                              \
        printf("post event %p", ev);  \
                                                                              \
    } else  {                                                                 \
        printf("update posted event %p", ev);                                 \
    }


#define ngx_delete_posted_event(ev)                                           \
                                                                              \
    *(ev->prev) = ev->next;                                                   \
                                                                              \
    if (ev->next) {                                                           \
        ev->next->prev = ev->prev;                                            \
    }                                                                         \
                                                                              \
    ev->prev = NULL;                                                          \
    printf("delete posted event %p", ev);

extern ngx_event_t  *ngx_posted_accept_events;
extern ngx_event_t  *ngx_posted_events;


#endif
